package com.alkandros.descuentosperu;

import com.alkandros.descuentosperu.manager.Utils;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends Activity implements OnClickListener{

	
	private Button buttonCoupons;
	private Button buttonSuperMarkets;
	private Button buttonRetailStores;
	private Button buttonFastFood;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		initialiseUI();
	}
	
	private void initialiseUI()
	{
		buttonCoupons  		= (Button)findViewById(R.id.buttonCoupons);
		buttonSuperMarkets  = (Button)findViewById(R.id.buttonSuperMarkets);
		buttonRetailStores  = (Button)findViewById(R.id.buttonRetailStores);
		buttonFastFood  	= (Button)findViewById(R.id.buttonFastFood);
		
		buttonCoupons.setOnClickListener(this);
		buttonSuperMarkets.setOnClickListener(this);
		buttonRetailStores.setOnClickListener(this);
		buttonFastFood.setOnClickListener(this);
		
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(Utils.getWidth(this)-200, LinearLayout.LayoutParams.WRAP_CONTENT);
		params.setMargins(0, 20, 0, 0);
		
		
		
		buttonCoupons.setLayoutParams(params);
		buttonSuperMarkets.setLayoutParams(params);
		buttonRetailStores.setLayoutParams(params);
		buttonFastFood.setLayoutParams(params);
		
		/*buttonCoupons.setBackground(getResources().getDrawable(R.drawable.rounded_button));
		buttonRetailStores.setBackgroundResource(R.drawable.rounded_button);
		buttonSuperMarkets.setBackgroundResource(R.drawable.rounded_button);
		buttonFastFood.setBackgroundResource(R.drawable.rounded_button);*/
	}

	@Override
	public void onClick(View v) {
		
		if(v==buttonCoupons)
		{
			SubMenuActivity.openActivity(this, 1);
		}
		else if(v==buttonSuperMarkets)
		{
			SubMenuActivity.openActivity(this, 2);
		}
		else if(v==buttonRetailStores)
		{
			SubMenuActivity.openActivity(this, 3);
		}
		else if(v==buttonFastFood)
		{
			SubMenuActivity.openActivity(this, 4);
		}
		
		
	}
}
